package io.renren.modules.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.admin.dao.CourseContentDao;
import io.renren.modules.admin.entity.CourseContentEntity;
import io.renren.modules.admin.service.CourseContentService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;



@Service("courseContentService")
public class CourseContentServiceImpl extends ServiceImpl<CourseContentDao, CourseContentEntity> implements CourseContentService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String contentTitle = params.get("contentTitle").toString();
        String courseId = params.get("courseId").toString();
        // 条件...
        QueryWrapper<CourseContentEntity> courseContentEntityQueryWrapper = new QueryWrapper<>();
        boolean notBlank = StringUtils.isNotBlank(contentTitle);
        courseContentEntityQueryWrapper.like(StringUtils.isNotBlank(contentTitle),"content_title",contentTitle);
        courseContentEntityQueryWrapper.eq(StringUtils.isNotBlank(courseId),"course_id",courseId);

        IPage<CourseContentEntity> page = this.page( new Query<CourseContentEntity>().getPage(params),courseContentEntityQueryWrapper );
        return new PageUtils(page);
    }

}